<?php
session_start();
include('inc/connection.php');

?>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="Hasan" content="EC" />
        <!--  CSS   -->
        <link href="css/en/mycss.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/header.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/footer.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/cart.css" rel="Stylesheet" type="text/css" />
        <link rel="shortcut icon" href="favicon.ico" />
        <!--  JS   -->
        <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script src="js/myjs.js"></script>
        <script src="js/cart.js"></script>
        <script src="js/header.js"></script>

        <title>Mobizoo Mobiles</title>
    </head>

    <!-- BODY -->
    <body>

        <!-- ********************************* -->
        <!-- header -->
        <!-- ********************************* -->
        <?php
        include('inc/header.php');
        ?>

        <!-- ********************************* -->
        <!-- Cart -->
        <!-- ********************************* -->
        <div id="cartContainer">
            <div id="cartProductsArea">
                <div id="cartProductsAreaTitle">
                    <img src="images/cartIcon.png"/>
                    <h2>Cart Items</h2>
                </div>
                <?php
                if (!isset($_SESSION['id'])) {
                    echo '<p>login to pruchase</p>'; 
                } else {

                    $sql = "SELECT * FROM `products`";
                    $result = mysql_query($sql);
                    //$cartActive = mysql_num_rows($result);
//                    echo mysql_num_rows($result);
                    while ($row = mysql_fetch_array($result)) {
					 $inCart = false;
					 $arrlength=count($_SESSION['cart']);

						for($x=0;$x<$arrlength;$x++){
						
						$arr = explode("," ,$_SESSION['cart'][$x]);
							if($arr[0] == $row['id']){
								$inCart = true;
						
		
							}
						}
						
						if($inCart){
							
                        $price = $row['price'];
                        echo '<div content="' . $row['id'] . '" class="cartProductsAreaSlices">
                                <div class="cartProductsAreaSlicesImage">
                                    <img src="../photos/thumb/' . $row['img'] . '" width = "100%" height="100%"/>
                                </div>
                                <div class="cartProductsAreaSlicesInfo">
                                    <div class="cartProductsAreaSlicesInfoTitle">
                                        <h3>' . $row['name_en'] . '</h3>
                                    </div>
                                    <div class="cartProductsAreaSlicesInfoDesc">
                                        <p> ' . $row['desc_en'] . ' </p>
                                    </div>
                                    <div class="cartProductsAreaSlicesInfoPrice">
                                        <p class="price" content="' . $price . '">||Price: ' . $price . '</p>
                                        <p class="totalPrice">||Total Price: ' . $price . '</p>
                                        <p>||views: ' . $row['visit_num'] . '</p>
                            
                                        <div class="cartProductsAreaSlicesInfoPriceButtons">
                                            <a href="javascript:void(0)" class="deleteFromCart" content=' . $row['id'] . '><img src="images/delete.png" width="20px" alt="delete" /></a>
                                            <input value="1" type="text" price="' . $price . '" class="qouantity" product="' . $row['id'] . '"/>
                                            <p>Quantity</p>
                                        </div>
                                    </div>

                                </div>
                            </div>';
						}
					
                    }
                    if ( count($_SESSION['cart']) == 0) {
                        echo '<div id="cartProductsAreaPerform">
                    <p style="display:block; margin:auto; width:180px; text-align:center; background-color:brown;color:white; border-radius:5px;">There is no products</p>
                    </div>';
                    } else {
                        echo '<div id="cartProductsAreaPerform">
                    <a class="approveBuy" href="javascript:void(0)">Approve Buying</a>
                    <a class="discardBuy" href="javascript:void(0)">Discard Cart</a>
                    </div>';
                    }
                }
                ?>
                <!--                <div class="cartProductsAreaSlices">
                                    <div class="cartProductsAreaSlicesImage">
                                        <img src="images/products/1332333052.jpg" height="90%"/>
                                    </div>
                                    <div class="cartProductsAreaSlicesInfo">
                                        <div class="cartProductsAreaSlicesInfoTitle">
                                            <h3>product</h3>
                                        </div>
                                        <div class="cartProductsAreaSlicesInfoDesc">
                                            <p>  معلومات معلومات معلومات معلومات معلومات معلوماتمعلوماتمعلومات معلومات معلومات معلوماتمعلوماتمعلومات معلوماتمعلومات معلوماتمعلوماتمعلوماتمعلومات  </p>
                                        </div>
                                        <div class="cartProductsAreaSlicesInfoPrice">
                                            <p>||Price: 55</p>
                                            <p>||views: 55</p>
                                            <p>||Bought: 55</p>
                                            <div class="cartProductsAreaSlicesInfoPriceButtons">
                                                <a href="javascript:void(0)"><img src="images/delete.png" width="20px" alt="delete" /></a>
                                                <input value="2" type="text" class="price"/>
                                                <p>Quantity</p>
                                            </div>
                                        </div>
                                        
                                    </div>
                                </div>-->
            </div>

        </div>

        <!-- ********************************* -->
        <!-- footer -->
        <!-- ********************************* -->
        <?php
       // include('inc/footer.php');
        ?>

    </body>
</html>